﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Engine.Classes.*;
    import flash.display.*;

	/**
	 *	RoadLayer跟普通的ObjectLayer的主要区别是他本身有三个层， 往它上面放的物品都是在m_baseObject上 
	 */
    public class RoadLayer extends ObjectLayer {

        private var m_baseObject:Sprite;
        private var m_topObject:Sprite;
        private var m_bottomObject:Sprite;

        public function RoadLayer(_arg1:String, _arg2:Number=0){
            super(_arg1, _arg2);
            this.m_baseObject = new Sprite();
            this.m_topObject = new Sprite();
            this.m_bottomObject = new Sprite();
            var _local3:Sprite = (m_displayObject as Sprite);
            if (_local3){
                _local3.addChild(this.m_bottomObject);
                _local3.addChild(this.m_baseObject);
                _local3.addChild(this.m_topObject);
            };
        }
        public function get topObject():Sprite{
            return (this.m_topObject);
        }
        public function get bottomObject():Sprite{
            return (this.m_bottomObject);
        }
        override public function cleanUp():void{
            super.cleanUp();
            if (this.m_baseObject.parent){
                this.m_baseObject.parent.removeChild(this.m_baseObject);
            };
            if (this.m_topObject.parent){
                this.m_topObject.parent.removeChild(this.m_topObject);
            };
            var _local1:Sprite = (m_displayObject as Sprite);
            if (_local1){
                _local1.addChild(this.m_baseObject);
                _local1.addChild(this.m_topObject);
            };
        }
        override public function insertObjectIntoDepthArray(_arg1:WorldObject, _arg2:String=null):void{
            var _local3:int = binarySearch(_arg1);
            m_children.splice(_local3, 0, _arg1);
            var _local4:DisplayObject = _arg1.getDisplayObject();
            var _local5:Sprite = this.m_baseObject;
            if (_local4 == null){
                _local5.addChildAt(_arg1.createDisplayObject(), _local3);
            } else {
                if (_local4.parent == null){
                    _local5.addChildAt(_local4, _local3);
                } else {
                    _local4.parent.setChildIndex(_local4, _local3);
                };
            };
        }

    }
}//package Classes 
